﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="OperationsTests.cs" company="dimamartovoi">
//   Apache License
//   Version 2.0, January 2004
//   http://www.apache.org/licenses
// </copyright>
// <summary>
//   The operations tests.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

using ActorModel.Evolution.Operations;

using NUnit.Framework;

namespace Evolution.Tests
{
    /// <summary>
    ///     The operations tests.
    /// </summary>
    [TestFixture]
    public class OperationsTests
    {
        #region Public Methods and Operators

        /// <summary>
        ///     The intersect test.
        /// </summary>
        [Test]
        public void IntersectTest()
        {
            const string Data1 = "100100";
            const string Data2 = "0011001";
            string intersect = Operations.Intersect(Data1, Data2);
            Assert.IsTrue(intersect == "000100");
        }

        /// <summary>
        ///     The inverse test.
        /// </summary>
        [Test]
        public void InverseTest()
        {
            const string Data = "01";
            string inversed = Operations.Inverse(Data);
            Assert.IsTrue(inversed == "10");
        }

        /// <summary>
        ///     The not test.
        /// </summary>
        [Test]
        public void NotTest()
        {
            const string Data = "1001001";
            string inversed = Operations.Not(Data);
            Assert.IsTrue(inversed == "0110110");
        }

        /// <summary>
        ///     The replace substring operation.
        /// </summary>
        [Test]
        public void ReplaceSubstringOperation()
        {
            const string Data1 = "01010001";
            const string Data2 = "01";
            string result = Operations.ReplaceSubstring(1, 2, Data2, null);
            Assert.IsTrue(result == "001");
        }

        /// <summary>
        ///     The union test.
        /// </summary>
        [Test]
        public void UnionTest()
        {
            const string Data1 = "1001001";
            const string Data2 = "00110011";
            string union = Operations.Union(Data1, Data2);
            Assert.IsTrue(union == "10110011");
        }

        /// <summary>
        ///     The xor test.
        /// </summary>
        [Test]
        public void XorTest()
        {
            const string Data1 = "100100101";
            const string Data2 = "0011001";
            string xor = Operations.Xor(Data1, Data2);
            Assert.IsTrue(xor == "1010000");
        }

        #endregion
    }
}